export const ApiClassDecorator = (path: string): ClassDecorator => {
  return (target) => {
    target.prototype.path = path;
  };
};

export const ApiMethodDecorator = (method: string, url?: string): MethodDecorator => {
  return (target: Object, propertyKey: string | symbol) => {
    const node = (url ? `${url}` : '') + ` ${method}`;
    if (!target['nodes']) target['nodes'] = {};
    setTimeout(() => {
      if (target['path']) {
        if (!target['nodes'][target['path']]) target['nodes'][target['path']] = {};
        target['nodes'][target['path']][propertyKey] = node;
      } else {
        if (!target['nodes']['basic']) target['nodes']['basic'] = {};
        target['nodes']['basic'][propertyKey] = node;
      }
    }, 0);
  };
};
